#include "Timer.h"

Timer* Timer::instance = NULL;

Timer::Timer()
{
	firstMeasure();
}

Timer* Timer::getInstance()
{
	if (instance == NULL) instance = new Timer();

	return instance;
}

void Timer::destroyInstance()
{
	delete instance;
	instance = NULL;
}

void Timer::firstMeasure()
{
	now = clock();
}

void Timer::Measure()
{
	last = now;
	now = clock();
	deltaTime = ((double)(now - last)) / CLOCKS_PER_SEC;
}

float Timer::getFPS()
{
	return 1 / deltaTime;
}

double Timer::getDT()
{
	return deltaTime;
}
